<?php
/**
 *
 *
 * @author Zeon <scplay@gmail.com>
 * @date 2018/11/27
 * @copyright PanxSoft Inc.
 */

namespace App\Models\Location;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
 * 市 / 区 同表
 *
 * @property string name
 *
 * @mixin Builder
 */
class City extends Model
{
    const UP_ID_TOP = 0;
    const CITY_STATUS_ON = 1;

    const CITY_UP_ID_ZERO = 0; // 地级市

    protected $guarded = [];

    protected $table = 'city';

    protected $primaryKey = 'city_id';

    public $appends = ['value'];

    /**
     * @return null
     */
    public function getValueAttribute()
    {
        if ($this->attributes['city_id']) {
            return $this->attributes['city_id'];
        } else {
            return null;
        }
    }
}